global citycontrol = "ihs_tj_dist ihs_sh_dist ihs_sz_dist ihs_bigcity_mindist"
global weathercontrol = "avtemp tosun dif_avtemp_3 dif_tosun_3"
***=====================CONTENT===========================
***Table 1: Air pollution and Actual Fertility Choice
    ***(a) OLS regression
    ***(b) IV regression 

***Table 2: Air pollution and the Ideal Number of Children
    ***(a) OLS regression
    ***(b) IV regression 
	
***Table A1: Summary Statistics 

***Table A3: Thermal Inversions and PM2.5 
	
***Table A4: Actual Fertility Decisions and Additional Controls
    ***(a) Add Housing Costs
    ***(b) Add Economic Controls
 	***(c) Add Hospital Infrastructures
    ***(d) Add Emissions Controls 
	
***Table A5: Add Weather and Geological Controls: For Thermal Inversions IV  
 
***Table A6: Adding all controls together

***Table A7: Accounting the Effect of Elevation: For Thermal Inversions IV
    ***(a) Limiting Cities to Those with Elevation<3 km
    ***(b) Control for Elevation

***Table A8: Ideal number of children and Additional Controls
    ***(a) Control for housing price
    ***(b) Control for other pollutant

***Table A9: Changes in Pollution and Fertility Choices 

***Table A10:  Wind Direction IV

***Table A11: Different Distance Bins for Selection of Power Plants

***Table A12: Excluding Newly Built Power Plants

***Table A13: Excluding Coal Producing Region

***Table A14: Controlling for Electricity Demand
    ***(a) Add Industrial Elec. Cons.
    ***(b) Add Elec. Cons. 

***Table A15: Baseline Economy and the Wind Direction IV

***Table A16: Wind Direction IV + Thermal Inversions

***Table A17: Results of Individual Longitudinal Panel

***Table A18: Using individuals who lived in their current residential province 5 years ago

***Table A19: Fertility Choices of Ethnic Minorities
    ***(a) Minority Women Who Hadn't Had Children One-Year Prior
    ***(b) Minority Women Irrespective of Childbearing Histories
	
***Table A20: Using Minority Samples Who Work in Urban Areas
    ***(a) Minority Women Who Hadn't Had Children One-Year Prior
    ***(b) Minority Women Irrespective of Childbearing Histories
	
***Table A21: A Random Han Sample with the Same Sample Size as the Minorities

***Table A22: The OCP and the Differential Fertility Response to Pollution

***Table A23: The OCP and Preferences for the College Education of Children

***Table A24: Early Childhood PM2.5 Exposure and Parental Expenditure

***Table A25: Differential Effected of Increased Pollution by Air Purifier Prices

***Table A26: Heterogenous Effects on Fertility Choices
    ***(a) Heterogeneity by mother's education levels
    ***(b) Heterogeneity by rates of return on human capital
	
***Table A27: Heterogeneous Effects by Income

***Table A28: Accounting for Income Effects on Actual Fertility Choices

***Table A29: Accounting for Income Effects on the Ideal Number of Children

***Table A30: Air Pollution and Infertility

***Table A31: Control for individual health status

***======================================================
*Table 1
use "$workdata\census_han_reg",clear
*Panel A: OLS
reghdfe give_birth pm25 dif_pm25_3 $citycontrol $weathercontrol , noabs cluster(des_city) keepsing
reghdfe give_birth pm25 dif_pm25_3 $citycontrol $weathercontrol ,abs(ranking) cluster(des_city) keepsing
reghdfe give_birth pm25 dif_pm25_3 $citycontrol $weathercontrol ,abs(ranking birthyear) cluster(des_city) keepsing
reghdfe give_birth pm25 dif_pm25_3 $citycontrol $weathercontrol ,abs(ranking#birthyear) cluster(des_city) keepsing

*Panel B: 2SLS
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol ,noabs cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol ,abs(ranking) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol ,abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol ,abs(ranking#birthyear) cluster(des_city) keepsing

*Table 2
use "$workdata\clds_willing",clear

*Panel A: OLS
reghdfe dream_child_num pm25 dif_pm25_3 married child_num,abs(des_city year source_city) cluster(des_city)
reghdfe dream_child_num pm25 dif_pm25_3 married child_num,abs(des_city year source_city birthyear) cluster(des_city)
reghdfe dream_child_num pm25 dif_pm25_3 married child_num $weathercontrol ,abs(des_city year source_city) cluster(des_city)
reghdfe dream_child_num pm25 dif_pm25_3 married child_num $weathercontrol ,abs(des_city year source_city birthyear) cluster(des_city)

*Panel B: 2SLS
ivreghdfe dream_child_num (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num,abs(des_city year source_city) cluster(des_city)
ivreghdfe dream_child_num (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num,abs(des_city year source_city birthyear) cluster(des_city)
ivreghdfe dream_child_num (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num $weathercontrol ,abs(des_city year source_city) cluster(des_city)
ivreghdfe dream_child_num (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num $weathercontrol ,abs(des_city year source_city birthyear) cluster(des_city)

*Table A1
use "$workdata\census_han_reg",clear
sum give_birth tj_dist sh_dist sz_dist bigcity_mindist avtemp tosun pm25

*Table A2
use "$workdata\census_han_reg",clear

*Panel A: Thermal Inversions IV
replace thermalstrength2009 = -thermalstrength2009
reghdfe pm25 thermalstrength2009 avtemp tosun $citycontrol, noabs cluster(des_city) keepsing
reghdfe pm25 thermalstrength2009 avtemp tosun $citycontrol, abs(ranking) cluster(des_city) keepsing
reghdfe pm25 thermalstrength2009 avtemp tosun $citycontrol, abs(ranking birthyear) cluster(des_city) keepsing
reghdfe pm25 thermalstrength2009 avtemp tosun $citycontrol, abs(ranking#birthyear) cluster(des_city) keepsing

*Panel B: Wind IV
replace total_coal50_450 = total_coal50_450/1000
reghdfe pm25 total_coal50_450 avtemp tosun $citycontrol, noabs cluster(des_city) keepsing
reghdfe pm25 total_coal50_450 avtemp tosun $citycontrol, abs(ranking) cluster(des_city) keepsing
reghdfe pm25 total_coal50_450 avtemp tosun $citycontrol, abs(ranking birthyear) cluster(des_city) keepsing
reghdfe pm25 total_coal50_450 avtemp tosun $citycontrol, abs(ranking#birthyear) cluster(des_city) keepsing

*Table A3
use "$rawdata\Thermal", clear
g cityid = code/100
sort cityid year
merge cityid year using "$rawdata\pm25_1998_2016.dta"
keep if _merge==3
drop _merge

bysort year: egen mean_thermalinversion=mean(thermalstrength)

gen group_num=(thermalstrength>mean_thermalinversion)
ttest pm25,by(group_num)

*Table A4
use "$workdata\census_han_reg",clear

*Add Housing Cost
local control = "price_2 growth_h_2"
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',noabs cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking#birthyear) cluster(des_city) keepsing

*Add Economic Controls
local control = "GDP_per_2 growth_GDP_per_2 growth_unemploy_2 unemploy_2"

ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',noabs cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking#birthyear) cluster(des_city) keepsing

*Add Hospital Infrastructures
local control = "num_bed_1 growth_num_bed_1 num_hosp_2 growth_num_hosp_2"
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',noabs cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking#birthyear) cluster(des_city) keepsing

*Add Emissions Controls
local control = "so2 growth_so2 no growth_no"
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',noabs cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking#birthyear) cluster(des_city) keepsing

*Table A5
local control = "nearocean00 oceanratio00 avwind avhumid torain dif_avwind_3 dif_avhumid_3 dif_torain_3"
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',noabs cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking#birthyear) cluster(des_city) keepsing

*Table A6
local control = "nearocean00 oceanratio00 avwind avhumid torain dif_avwind_3 dif_avhumid_3 dif_torain_3 GDP_per_2 growth_GDP_per_2 growth_unemploy_2 unemploy_2 price_2 growth_h_2 num_bed_1 growth_num_bed_1 so2 growth_so2 no growth_no"
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',noabs cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking#birthyear) cluster(des_city) keepsing

*Table A7
merge m:1 cityid using "$workdata\elevation_wk"
drop if _m == 2
drop _m
drop if alttud==.
g high_city = alttud>3000
*Panel A
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol if high_city==0,noabs cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol if high_city==0,abs(ranking) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol if high_city==0,abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol if high_city==0,abs(ranking#birthyear) cluster(des_city) keepsing

*Panel B
local control = "alttud"
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',noabs cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking#birthyear) cluster(des_city) keepsing

*Table A8
use "$workdata\clds_willing",clear
*Panel A: Control for housing price
local control = "rent_per dif_rent"
ivreghdfe dream_child_num (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num `control' if minority==0,abs(des_city year source_city) cluster(des_city) 
ivreghdfe dream_child_num (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num `control',abs(des_city year source_city birthyear) cluster(des_city)
ivreghdfe dream_child_num (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num $weathercontrol `control',abs(des_city year source_city) cluster(des_city)
ivreghdfe dream_child_num (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num $weathercontrol `control',abs(des_city year source_city birthyear) cluster(des_city) 

*Panel B: Control for other pollutant
local control = "so2 dif_so2 no dif_no"
ivreghdfe dream_child_num (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num `control',abs(des_city year source_city) cluster(des_city)
ivreghdfe dream_child_num (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num `control',abs(des_city year source_city birthyear) cluster(des_city)
ivreghdfe dream_child_num (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num $weathercontrol `control',abs(des_city year source_city) cluster(des_city)
ivreghdfe dream_child_num (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num $weathercontrol `control',abs(des_city year source_city birthyear) cluster(des_city)

*Table A9
use "$workdata\census_han_reg",clear

foreach j in 2 4 6 10 {
    
	ivreghdfe give_birth (pm25 dif_pm25_`j'=thermalstrength2009 dif_thermalstrength_`j') $citycontrol,abs(ranking birthyear) cluster(des_city)

}

*Table A10
use "$workdata\census_han_reg",clear
merge m:1 des_city using windiv
keep if _m == 3
drop _m

ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450 dif_total_coal50_450) $citycontrol $weathercontrol ,noabs cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450 dif_total_coal50_450) $citycontrol $weathercontrol ,abs(ranking) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450 dif_total_coal50_450) $citycontrol $weathercontrol ,abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450 dif_total_coal50_450) $citycontrol $weathercontrol ,abs(ranking#birthyear) cluster(des_city) keepsing

*Table A11
foreach i in 50 60 110 150 {
	
	ivreghdfe give_birth (pm25 dif_pm25_3=total_coal`i'_450 dif_total_coal`i'_450) $citycontrol $weathercontrol ,noabs cluster(des_city) keepsing
	ivreghdfe give_birth (pm25 dif_pm25_3=total_coal`i'_450 dif_total_coal`i'_450) $citycontrol $weathercontrol ,abs(ranking) cluster(des_city) keepsing
	ivreghdfe give_birth (pm25 dif_pm25_3=total_coal`i'_450 dif_total_coal`i'_450) $citycontrol $weathercontrol ,abs(ranking birthyear) cluster(des_city) keepsing
	ivreghdfe give_birth (pm25 dif_pm25_3=total_coal`i'_450 dif_total_coal`i'_450) $citycontrol $weathercontrol ,abs(ranking#birthyear) cluster(des_city) keepsing
}

*Table A12
foreach i in 5 15 20 25 {
	
	ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450_`i'y dif_total_coal50_450_`i'y) $citycontrol $weathercontrol ,noabs cluster(des_city) keepsing
	ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450_`i'y dif_total_coal50_450_`i'y) $citycontrol $weathercontrol ,abs(ranking) cluster(des_city) keepsing
	ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450_`i'y dif_total_coal50_450_`i'y) $citycontrol $weathercontrol ,abs(ranking birthyear) cluster(des_city) keepsing
	ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450_`i'y dif_total_coal50_450_`i'y) $citycontrol $weathercontrol ,abs(ranking#birthyear) cluster(des_city) keepsing
}

*Table A13
ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450 dif_total_coal50_450) $citycontrol $weathercontrol if des_prov!=14,noabs cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450 dif_total_coal50_450) $citycontrol $weathercontrol if des_prov!=14,abs(ranking) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450 dif_total_coal50_450) $citycontrol $weathercontrol if des_prov!=14,abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450 dif_total_coal50_450) $citycontrol $weathercontrol if des_prov!=14,abs(ranking#birthyear) cluster(des_city) keepsing

*Table A14
merge m:1 des_city using "$workdata\elec"
keep if _m == 3
drop _m

*Panel A
g log_total_elec = log(total_elec)
g log_dif_total_elec = log(dif_total_elec)
g ihs_dif_total_elec = asinh(dif_total_elec)
g log_ind_elec = log(ind_elec)
g log_dif_ind_elec = log(dif_ind_elec)
g ihs_dif_ind_elec = asinh(dif_ind_elec)

local control = "log_ind_elec ihs_dif_ind_elec"
ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450 dif_total_coal50_450) $citycontrol $weathercontrol `control',noabs cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450 dif_total_coal50_450) $citycontrol $weathercontrol `control',abs(ranking) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450 dif_total_coal50_450) $citycontrol $weathercontrol `control',abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450 dif_total_coal50_450) $citycontrol $weathercontrol `control',abs(ranking#birthyear) cluster(des_city) keepsing

*Panel B
local control = "log_total_elec ihs_dif_total_elec"
ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450 dif_total_coal50_450) $citycontrol $weathercontrol `control',noabs cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450 dif_total_coal50_450) $citycontrol $weathercontrol `control',abs(ranking) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450 dif_total_coal50_450) $citycontrol $weathercontrol `control',abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450 dif_total_coal50_450) $citycontrol $weathercontrol `control',abs(ranking#birthyear) cluster(des_city) keepsing

*Table A15
use "$workdata\total_coal_2009_v1_km_balance", clear
merge 1:1 des_city using "$workdata\city_2004"
keep if _m==3
drop _m

g procode = int(des_city/100)
sort des_city

*ranking 
gen regioncode=1 if procode==37|procode==32|procode==34|procode==33|procode==35|procode==31 
replace regioncode=2 if procode==44|procode==45|procode==46
replace regioncode=3 if procode==42|procode==43|procode==41|procode==36
replace regioncode=4 if procode==11|procode==12|procode==13|procode==14|procode==15
replace regioncode=5 if procode==64 |procode==65 |procode==63|procode==61|procode==62
replace regioncode=6 if procode==51 |procode==53 |procode==52|procode==54|procode==50
replace regioncode=7 if procode==21 |procode==22 |procode==23

gen cityid=des_city

gen procity=(cityid==1100|cityid==3100|cityid==1200|cityid==5000)
gen subprocity=(cityid==2101|cityid==2102|cityid==2201|cityid==2301| ///
cityid==3201|cityid==3301|cityid==3302|cityid==3502|cityid==3701|cityid==3702|cityid==4201|cityid==4401 ///
|cityid==4403|cityid==5101|cityid==6101 )
gen procapital=(cityid==1301|cityid==1401|cityid==1501|cityid==3401|cityid==3501|cityid==3601| ///
cityid==4101|cityid==4301|cityid==4501|cityid==4601|cityid==5201|cityid==5301|cityid==6201 ///
|cityid==6301|cityid==6401|cityid==6501)

g ranking=2
replace ranking=1 if procity==1
replace ranking=1 if subprocity==1
replace ranking=1 if procapital==1

g log_pop = log(pop)
g log_total_elec = log(total_elec)
g log_ind_elec = log(ind_elec)
g log_GDP = log(GDP)
g total_coal50_450_r = total_coal50_450/1000
recode share_up . = 0
replace GDP = GDP/1000000
replace pop = pop/100
for var total_elec ind_elec: replace X = X/10000
drop if total_elec == .

reg share_up GDP log_pop log_total_elec log_ind_elec i.regioncode,cluster(des_city) 
reg share_up GDP log_pop log_total_elec log_ind_elec i.ranking i.regioncode,cluster(des_city) 
reg total_coal50_450_r GDP log_pop log_total_elec log_ind_elec i.regioncode, cluster(des_city) 
reg total_coal50_450_r GDP log_pop log_total_elec log_ind_elec  i.ranking i.regioncode, cluster(des_city) 

*Table A16
use "$workdata\census_han_reg",clear
merge m:1 des_city using windiv
keep if _m == 3
drop _m

ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450 dif_total_coal50_450 thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol ,noabs cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450 dif_total_coal50_450 thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol ,abs(ranking) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450 dif_total_coal50_450 thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol ,abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=total_coal50_450 dif_total_coal50_450 thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol ,abs(ranking#birthyear) cluster(des_city) keepsing

*Table A17
use "$workdata\clds_tracking_14", clear

*Panel A: Baseline 
ivreghdfe givebirth (pm25 dif_pm25=thermalstrength dif_thermalstrength) child_num,abs(IID year#regioncode c.year#regioncode_birth) cluster(des_city)
ivreghdfe givebirth (pm25 dif_pm25=thermalstrength dif_thermalstrength) child_num,abs(IID year#regioncode ranking c.year#ranking c.year#regioncode_birth) cluster(des_city)
ivreghdfe givebirth (pm25 dif_pm25=thermalstrength dif_thermalstrength) child_num,abs(IID year#regioncode ranking#year c.year#regioncode_birth) cluster(des_city)
ivreghdfe givebirth (pm25 dif_pm25=thermalstrength dif_thermalstrength) child_num,abs(IID year#regioncode#ranking c.year#regioncode_birth) cluster(des_city)

*Panel B: Add weathercontrol
ivreghdfe givebirth (pm25 dif_pm25=thermalstrength dif_thermalstrength) child_num avtemp tosun dif_avtemp dif_tosun,abs(IID year#regioncode) cluster(des_city)
ivreghdfe givebirth (pm25 dif_pm25=thermalstrength dif_thermalstrength) child_num avtemp tosun dif_avtemp dif_tosun,abs(IID year#regioncode ranking) cluster(des_city)
ivreghdfe givebirth (pm25 dif_pm25=thermalstrength dif_thermalstrength) child_num avtemp tosun dif_avtemp dif_tosun,abs(IID year#regioncode ranking#year) cluster(des_city)
ivreghdfe givebirth (pm25 dif_pm25=thermalstrength dif_thermalstrength) child_num avtemp tosun dif_avtemp dif_tosun,abs(IID year#regioncode#ranking) cluster(des_city)


*Table A18
use "$workdata\census_han_reg",clear
keep if sameprov==1
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol ,noabs cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol ,abs(ranking) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol ,abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol ,abs(ranking#birthyear) cluster(des_city) keepsing

*Table A19
use "$workdata\census_minority_reg", clear
*Panel B
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) child_num $citycontrol $weathercontrol, abs( ) cluster(des_city)
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) child_num $citycontrol $weathercontrol, abs(ranking) cluster(des_city)
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) child_num $citycontrol $weathercontrol, abs(ranking birthyear) cluster(des_city)
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) child_num $citycontrol $weathercontrol, abs(ranking#birthyear) cluster(des_city)

*Panel A
keep if (child_num == 0)|(child_num == 1&give_birth==1)|(child_num == 2 &give_birth==1&second_baby == 1)
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol, abs( ) cluster(des_city)
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol, abs(ranking) cluster(des_city)
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol, abs(ranking birthyear) cluster(des_city)
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol, abs(ranking#birthyear) cluster(des_city)


*Table A20
use "$workdata\census_minority_reg", clear
keep if rural_hk==0&employed==1
*Panel B
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) child_num $citycontrol $weathercontrol, abs( ) cluster(des_city)
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) child_num $citycontrol $weathercontrol, abs(ranking) cluster(des_city)
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) child_num $citycontrol $weathercontrol, abs(ranking birthyear) cluster(des_city)
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) child_num $citycontrol $weathercontrol, abs(ranking#birthyear) cluster(des_city)

*Panel A
keep if (child_num == 0)|(child_num == 1&give_birth==1)|(child_num == 2 &give_birth==1&second_baby == 1)
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol, abs( ) cluster(des_city)
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol, abs(ranking) cluster(des_city)
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol, abs(ranking birthyear) cluster(des_city)
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol, abs(ranking#birthyear) cluster(des_city)

*Panel A21
use "$workdata\census_han_raw",clear
for var give_birth pm25 dif_pm25_3 thermalstrength2009 dif_thermalstrength_3 avtemp tosun dif_avtemp_3 dif_tosun_3 ihs_tj_dist ihs_sh_dist ihs_sz_dist ihs_bigcity_mindist:drop if X==.
set seed 123456
sample 11103,count

ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol ,noabs cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol ,abs(ranking) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol ,abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol ,abs(ranking#birthyear) cluster(des_city) keepsing

*Panel A22
use "$workdata\census_total_reg",clear

ivreghdfe give_birth (pm25 dif_pm25_3 c.dif_pm25_3#c.log_fine_income c.dif_pm25_3#c.han c.dif_pm25_3#c.log_fine_income#c.han=thermalstrength2009 dif_thermalstrength_3 c.dif_thermalstrength_3#c.log_fine_income c.dif_thermalstrength_3#c.han c.dif_thermalstrength_3#c.log_fine_income#c.han) han log_fine_income c.log_fine_income#c.han $weathercontrol ,abs(des_city) cluster(des_city) keepsing

ivreghdfe give_birth (pm25 dif_pm25_3 c.dif_pm25_3#c.log_fine_income c.dif_pm25_3#c.han c.dif_pm25_3#c.log_fine_income#c.han=thermalstrength2009 dif_thermalstrength_3 c.dif_thermalstrength_3#c.log_fine_income c.dif_thermalstrength_3#c.han c.dif_thermalstrength_3#c.log_fine_income#c.han) han log_fine_income c.log_fine_income#c.han $weathercontrol ,abs(des_city birthyear) cluster(des_city) keepsing

ivreghdfe give_birth (pm25 dif_pm25_3 c.dif_pm25_3#c.log_fine_income c.dif_pm25_3#c.han c.dif_pm25_3#c.log_fine_income#c.han=thermalstrength2009 dif_thermalstrength_3 c.dif_thermalstrength_3#c.log_fine_income c.dif_thermalstrength_3#c.han c.dif_thermalstrength_3#c.log_fine_income#c.han) han log_fine_income c.log_fine_income#c.han $weathercontrol ,abs(des_city birthyear des_city#c.birthyear) cluster(des_city) keepsing 

*Panel A23
use "$workdata\willing_15",clear
reghdfe antic_high log_fine_income,noabs cluster(des_city) keepsing
reghdfe antic_high log_fine_income,abs(ranking) cluster(des_city) keepsing
reghdfe antic_high log_fine_income $citycontrol ,noabs cluster(des_city) keepsing
reghdfe antic_high log_fine_income $citycontrol ,abs(ranking) cluster(des_city) keepsing

*Panel A24
use "$workdata\CFPS_2014_exp", clear
**Total expenditure
ivreghdfe ihs_exp (mean_pm25=mean_thermalstrength) mean_avtemp mean_tosun $citycontrol ,abs( ) cluster(des_city) keepsing
ivreghdfe ihs_exp (mean_pm25=mean_thermalstrength) mean_avtemp mean_tosun $citycontrol ,abs(ranking) cluster(des_city) keepsing
ivreghdfe ihs_exp (mean_pm25=mean_thermalstrength) mean_avtemp mean_tosun $citycontrol ,abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe ihs_exp (mean_pm25=mean_thermalstrength) mean_avtemp mean_tosun $citycontrol ,abs(ranking#birthyear) cluster(des_city) keepsing

**Health Expenditure
ivreghdfe ihs_sick_exp (mean_pm25=mean_thermalstrength) mean_avtemp mean_tosun $citycontrol ,abs( ) cluster(des_city) keepsing
ivreghdfe ihs_sick_exp (mean_pm25=mean_thermalstrength) mean_avtemp mean_tosun $citycontrol ,abs(ranking) cluster(des_city) keepsing
ivreghdfe ihs_sick_exp (mean_pm25=mean_thermalstrength) mean_avtemp mean_tosun $citycontrol ,abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe ihs_sick_exp (mean_pm25=mean_thermalstrength) mean_avtemp mean_tosun $citycontrol ,abs(ranking#birthyear) cluster(des_city) keepsing

**Education Expenditure
ivreghdfe ihs_edu_exp (mean_pm25=mean_thermalstrength) mean_avtemp mean_tosun $citycontrol ,abs( ) cluster(des_city) keepsing
ivreghdfe ihs_edu_exp (mean_pm25=mean_thermalstrength) mean_avtemp mean_tosun $citycontrol ,abs(ranking) cluster(des_city) keepsing
ivreghdfe ihs_edu_exp (mean_pm25=mean_thermalstrength) mean_avtemp mean_tosun $citycontrol ,abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe ihs_edu_exp (mean_pm25=mean_thermalstrength) mean_avtemp mean_tosun $citycontrol ,abs(ranking#birthyear) cluster(des_city) keepsing

*Panel A25
use "$workdata\census_han_reg",clear
sort des_prov
merge m:1 des_city using "$workdata\airfilter_city"
keep if _m == 3

keep if price!=.
for var price price_hepa price_nonhepa: replace X = X/1000
*Hepa
ivreghdfe give_birth (pm25 dif_pm25_3 c.dif_pm25_3#c.price_hepa=thermalstrength2009 dif_thermalstrength_3 c.dif_thermalstrength_3#c.price_hepa) price_hepa $citycontrol $weathercontrol ,abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3 c.dif_pm25_3#c.price_hepa=thermalstrength2009 dif_thermalstrength_3 c.dif_thermalstrength_3#c.price_hepa) price_hepa $citycontrol $weathercontrol ,abs(ranking#birthyear) cluster(des_city) keepsing
*Non-Hepa
ivreghdfe give_birth (pm25 dif_pm25_3 c.dif_pm25_3#c.price_nonhepa=thermalstrength2009 dif_thermalstrength_3 c.dif_thermalstrength_3#c.price_nonhepa) price_nonhepa $citycontrol $weathercontrol ,abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3 c.dif_pm25_3#c.price_nonhepa=thermalstrength2009 dif_thermalstrength_3 c.dif_thermalstrength_3#c.price_nonhepa) price_nonhepa $citycontrol $weathercontrol ,abs(ranking#birthyear) cluster(des_city) keepsing

*Panel A26
use "$workdata\census_han_reg",clear

*Panel A
ivreghdfe give_birth (pm25 dif_pm25_3 c.dif_pm25_3#c.school_years=thermalstrength2009 dif_thermalstrength_3 c.dif_thermalstrength_3#c.log_school_years) log_school_years $citycontrol $weathercontrol ,noabs cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3 c.dif_pm25_3#c.school_years=thermalstrength2009 dif_thermalstrength_3 c.dif_thermalstrength_3#c.log_school_years) log_school_years $citycontrol $weathercontrol ,abs(ranking) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3 c.dif_pm25_3#c.school_years=thermalstrength2009 dif_thermalstrength_3 c.dif_thermalstrength_3#c.log_school_years) log_school_years $citycontrol $weathercontrol ,abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3 c.dif_pm25_3#c.school_years=thermalstrength2009 dif_thermalstrength_3 c.dif_thermalstrength_3#c.log_school_years) log_school_years $citycontrol $weathercontrol ,abs(ranking#birthyear) cluster(des_city) keepsing

*Panel B
*Education return
use "$workdata\census_han_reg",clear
merge m:1 des_city using edu_return
keep if _m == 3
drop _m

ivreghdfe give_birth (pm25 dif_pm25_3 c.dif_pm25_3#c.precoll_return=thermalstrength2009 dif_thermalstrength_3 c.dif_thermalstrength_3#c.precoll_return) precoll_return $citycontrol $weathercontrol ,noabs cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3 c.dif_pm25_3#c.precoll_return=thermalstrength2009 dif_thermalstrength_3 c.dif_thermalstrength_3#c.precoll_return) precoll_return $citycontrol $weathercontrol ,abs(ranking) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3 c.dif_pm25_3#c.precoll_return=thermalstrength2009 dif_thermalstrength_3 c.dif_thermalstrength_3#c.precoll_return) precoll_return $citycontrol $weathercontrol ,abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3 c.dif_pm25_3#c.precoll_return=thermalstrength2009 dif_thermalstrength_3 c.dif_thermalstrength_3#c.precoll_return) precoll_return $citycontrol $weathercontrol ,abs(ranking#birthyear) cluster(des_city) keepsing

*Panel A27
use "$workdata\clds_willing",clear
bys year: egen mean_income = mean(income)
bys year: g high_income = income>mean_income&income<.
replace high_income = . if income == .
ivreghdfe dream_child_num (pm25 dif_pm25_3 c.dif_pm25_3#c.high_income=thermalstrength dif_thermalstrength_3 c.dif_thermalstrength_3#c.high_income) high_income married child_num,abs(des_city year source_city) cluster(des_city)
ivreghdfe dream_child_num (pm25 dif_pm25_3 c.dif_pm25_3#c.high_income=thermalstrength dif_thermalstrength_3 c.dif_thermalstrength_3#c.high_income) high_income married child_num,abs(des_city year source_city birthyear) cluster(des_city)
ivreghdfe dream_child_num (pm25 dif_pm25_3 c.dif_pm25_3#c.high_income=thermalstrength dif_thermalstrength_3 c.dif_thermalstrength_3#c.high_income) high_income married child_num $weathercontrol ,abs(des_city year source_city) cluster(des_city)
ivreghdfe dream_child_num (pm25 dif_pm25_3 c.dif_pm25_3#c.high_income=thermalstrength dif_thermalstrength_3 c.dif_thermalstrength_3#c.high_income) high_income married child_num $weathercontrol ,abs(des_city year source_city birthyear) cluster(des_city)

*Panel A28
use "$workdata\census_han_reg",clear
g log_income_1 = log(income_1)
local control = "log_income_1 growth_income_1"
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',noabs cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking birthyear) cluster(des_city) keepsing
ivreghdfe give_birth (pm25 dif_pm25_3=thermalstrength2009 dif_thermalstrength_3) $citycontrol $weathercontrol `control',abs(ranking#birthyear) cluster(des_city) keepsing

*Panel A29
use "$workdata\clds_willing",clear
local control = "income_1 dif_income_1"
ivreghdfe dream_child_num (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num `control',abs(des_city year source_city) cluster(des_city)
ivreghdfe dream_child_num (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num `control',abs(des_city year source_city birthyear) cluster(des_city)
ivreghdfe dream_child_num (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num $weathercontrol `control',abs(des_city year source_city) cluster(des_city)
ivreghdfe dream_child_num (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num $weathercontrol `control',abs(des_city year source_city birthyear) cluster(des_city)

*Panel A30
use "$workdata\infertility",clear
ivreghdfe infertility (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num ,abs(des_city year source_city) cluster(des_city)
ivreghdfe infertility (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num ,abs(des_city year source_city birthyear) cluster(des_city) 
ivreghdfe infertility (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num $weathercontrol ,abs(des_city year source_city) cluster(des_city)
ivreghdfe infertility (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num $weathercontrol ,abs(des_city year source_city birthyear) cluster(des_city)

*Panel A31
use "$workdata\clds_willing",clear
ivreghdfe dream_child_num (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num i.health_level,abs(des_city year source_city) cluster(des_city) keepsing
ivreghdfe dream_child_num (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num i.health_level,abs(des_city year source_city birthyear) cluster(des_city) keepsing
ivreghdfe dream_child_num (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num $weathercontrol i.health_level,abs(des_city year source_city) cluster(des_city) keepsing
ivreghdfe dream_child_num (pm25 dif_pm25_3=thermalstrength dif_thermalstrength_3) married child_num $weathercontrol i.health_level,abs(des_city year source_city birthyear) cluster(des_city) keepsing





